<script type="text/javascript">
	function doSearchPlayMember(value) {
		
	}
	
	//表格查询  
	function reloadPlayMember() {
		var params = playMember_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		playMember_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		playMember_list.datagrid('unselectAll');
		playMember_list.datagrid('uncheckAll');
	}


	function addPlayMember() {
		createFromWindow("新增信息", "playMember.do?editPlayMember", "playMember.do?savePlayMember",
				function(data) {
					reloadPlayMember();
				});
	}
	
	function deletePlayMember() {
		var rows = playMember_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('playMember.do?deletePlayMemberItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadPlayMember();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editPlayMember() {
		var rows = playMember_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "playMember.do?editPlayMember&playMemberId=" + rows[0].id,
					"playMember.do?savePlayMember", function(data) {
						reloadPlayMember();
					},true);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookPlayMember(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = playMember_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "playMember.do?editPlayMember&playMemberId=" + id,
					null, null,false);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditPlayMember(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = playMember_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "playMember.do?editPlayMember&playMemberId=" + id,
					"playMember.do?savePlayMember", function(data) {
						reloadPlayMember();
					},true);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsSendPlayMember() {
		printLog('发送');
	}
	
	function operationsDeletePlayMember(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('playMember.do?deletePlayMemberItems', {
						ids : id
					}, function(result) {
						if (result.success) {
							reloadPlayMember(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function clearPlayMemberSearch() {
		setGridSearchParams('playMember_list','playMemberSearchForm',true,reloadPlayMember);
	}
	
	//根据条件查询
	function playMemberSearch() {
		setGridSearchParams('playMember_list','playMemberSearchForm',false,reloadPlayMember);
	}
	
	//操作玩家状态
	function operationPlayMemberStatus(flag) {
		
	}
	//提取操作
	function extractPlay() {
		var rows = playMember_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow(rows[0].name+"-资金提取操作", "playMember.do?skip&page=outPlayAccount&memberId=" + rows[0].id,
					"playTradeRecord.do?outPlayAccount", function(data) {
						reloadPlayMember();
					},true,550,320);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	//充值操作
	function rechargePlay() {
		var rows = playMember_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow(rows[0].name+"-资金充值操作", "playMember.do?skip&page=inPlayAccount&memberId=" + rows[0].id,
					"playTradeRecord.do?inPlayAccount", function(data) {
						reloadPlayMember();
					},true,550,320);
		} else {
			showMsg('请选择操作记录.');
		}
	}
	//查看交易记录
	function playTradeRecode() {
		var rows = playMember_list.datagrid('getChecked');
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow(rows[0].name+"-交易记录", "playMember.do?skip&page=playTradeRecord&memberId=" + rows[0].id,
					"transAccount.do?saveTransAccount", function(data) {
						reloadTransAccount();
					},false,1000,600);
		} else {
			showMsg('请选择操作记录.');
		}
	}
</script>

<#assign operations = "[\{shiro:'play:playMember:refresh',onClick:'operationsLookPlayMember',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'play:playMember:edit',onClick:'operationsEditPlayMember',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'play:playMember:delete',onClick:'operationsDeletePlayMember',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="playMember_list" toolbar="#playMemberlist_search" idField="id" operations="${operations!}"
			 url="playMember.do?loadList" rownumbers="true"
			 item="com.xdtech.play.vo.PlayMemberItem"/>
		
		<div id="playMemberlist_search">
			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;">
				<form id="playMemberSearchForm">
					<!-- 防止form表单里只有一个text元素时候，按enter键自动提交问题 -->
					<input style="display:none" />
					<table>
						<tr>
							<td>玩家名称：</td>
							<td><input class="easyui-validatebox textbox" name="name" /></td>
							<td>
								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="playMemberSearch()"/>
	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearPlayMemberSearch()"/>
 					 		</td>
						</tr>
					</table>
				</form>
				
			</div>
			<div id="playMember_toolbar" style="height: auto">
				<@eu.linkbutton showName="新增" shiro="play:playMember:add" iconCls="icon-add" onclick="addPlayMember()"/>
				<@eu.linkbutton showName="删除" shiro="play:playMember:delete" iconCls="icon-remove" onclick="deletePlayMember()"/>
				<@eu.linkbutton showName="编辑" shiro="play:playMember:edit" iconCls="icon-edit" onclick="editPlayMember()"/>
				<@eu.linkbutton showName="充值" shiro="play:playMember:recharge" iconCls="icon-import" onclick="rechargePlay()"/>
				<@eu.linkbutton showName="提取" shiro="play:playMember:extract" iconCls="icon-export" onclick="extractPlay()"/>
				<@eu.linkbutton showName="交易记录" shiro="play:playMember:tradeRecord" iconCls="icon-save" onclick="playTradeRecode()"/>
<!-- 				<@eu.linkbutton showName="禁用" shiro="play:playMember:disable" iconCls="icon-disable" onclick="operationPlayMemberStatus(0)"/> -->
<!-- 				<@eu.linkbutton showName="启用" shiro="play:playMember:enable" iconCls="icon-ok" onclick="operationPlayMemberStatus(1)"/> -->
				<@eu.linkbutton showName="刷新" shiro="play:playMember:refresh" iconCls="icon-reload" onclick="reloadPlayMember()"/>
				
			</div>
		</div>
	</div>
</div>